//
// Created by meowch on 19-9-10.
//

#ifndef LIBDL_CORE_LAYOUT_H
#define LIBDL_CORE_LAYOUT_H

#endif //LIBDL_CORE_LAYOUT_H

#pragma once

enum class LayoutType : int8_t {
    Strided = int8_t(at::kStrided),
    Sparse = int8_t(at::kSparse),
    Mkldnn = int8_t(at::kMkldnn)
};

class Layout {
public:
    using core_type = c10::Layout;
    core_type core;
    ENABLE_CAST;
    explicit Layout(LayoutType layoutType) {
        core = to_core(layoutType);
    }
    static core_type layoutType(LayoutType layoutType) {
        return to_core(layoutType);
    }

private:
    static core_type to_core(LayoutType layoutType) {
        switch (layoutType) {
            case LayoutType::Strided:
                return at::kStrided;
            case LayoutType::Sparse:
                return at::kSparse;
            case LayoutType::Mkldnn:
                return at::kMkldnn;
            default:
                AT_ERROR("Unknown layout");
        }
    }
};

